import java.text.ParseException;
import java.util.Scanner;

public class Test {//自定义异常登录的实现
    private  static String name="user";
    private  static String password="123456";

    public static void main(String[] args)throws NameException,PasswordException {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入用户名");
        String name=scanner.next();
        System.out.println("请输入密码");
        String password=scanner.next();
        login(name,password);

    }
    public  static  void login(String name,String password) throws NameException,PasswordException{
        if(!Test.name.equals(name)){
            throw  new NameException("用户名错误");
        }
        if(!Test.password.equals(password)){
            throw  new PasswordException("密码错误");
        }
        System.out.println("登陆成功");

    }
}
